package com.qf.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.pojo.BookPatientVo;
import com.qf.pojo.BookingPojo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BookMapper extends BaseMapper<BookingPojo> {
    @Select("SELECT b.*,p.*,u.`user_name` FROM booking b LEFT JOIN patient p ON b.patient_id=p.patient_id LEFT JOIN USER u ON u.user_id=p.user_id ${ew.customSqlSegment}")
    Page<BookPatientVo> getPageVo(Page<BookPatientVo> page,@Param(Constants.WRAPPER)  QueryWrapper<BookingPojo> wrapper);




    @Select("SELECT b.*,p.*,u.`user_name` FROM booking b LEFT JOIN patient p ON b.patient_id=p.patient_id LEFT JOIN USER u ON u.user_id=p.user_id ${ew.customSqlSegment}")
    List<BookPatientVo> findByDay(@Param(Constants.WRAPPER)QueryWrapper<BookingPojo> wrapper);

    @Select("SELECT b.*,p.*,u.`user_name` FROM booking b LEFT JOIN patient p ON b.patient_id=p.patient_id LEFT JOIN USER u ON u.user_id=p.user_id ${ew.customSqlSegment}")
    List<BookPatientVo> findByNameOrTel(@Param(Constants.WRAPPER)QueryWrapper<BookingPojo> wrapper);
}
